package 多线程;

import javax.swing.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author : K k
 * @date : 15:20 2020/9/2
 *
 */
public class S {

    public synchronized void action(){
            for (int i=0;i<10;i++){
                System.out.print(i+" ");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
    }

    public static void main(String[] args) {

        S s1=new S();
        S s2=new S();
        String s3="sss";
        String s4="sss";
        System.out.println(s3==s4);
        System.out.println(s3.equals(s4));

        ExecutorService executorService = Executors.newCachedThreadPool();
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                s1.action();
            }
        });
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                s1.action();
            }
        });
    }
}
